package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysAllowbid;
import com.ruoyi.system.service.ISysAllowbidService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 允许竞价Controller
 * 
 * @author ruoyi
 * @date 2020-12-13
 */
@Controller
@RequestMapping("/system/allowbid")
public class SysAllowbidController extends BaseController
{
    private String prefix = "system/allowbid";

    @Autowired
    private ISysAllowbidService sysAllowbidService;

    @RequiresPermissions("system:allowbid:view")
    @GetMapping()
    public String allowbid()
    {
        return prefix + "/allowbid";
    }

    /**
     * 查询允许竞价列表
     */
    @RequiresPermissions("system:allowbid:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysAllowbid sysAllowbid)
    {
        startPage();
        List<SysAllowbid> list = sysAllowbidService.selectSysAllowbidList(sysAllowbid);
        return getDataTable(list);
    }

    /**
     * 导出允许竞价列表
     */
    @RequiresPermissions("system:allowbid:export")
    @Log(title = "允许竞价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysAllowbid sysAllowbid)
    {
        List<SysAllowbid> list = sysAllowbidService.selectSysAllowbidList(sysAllowbid);
        ExcelUtil<SysAllowbid> util = new ExcelUtil<SysAllowbid>(SysAllowbid.class);
        return util.exportExcel(list, "allowbid");
    }

    /**
     * 新增允许竞价
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存允许竞价
     */
    @RequiresPermissions("system:allowbid:add")
    @Log(title = "允许竞价", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysAllowbid sysAllowbid)
    {
        return toAjax(sysAllowbidService.insertSysAllowbid(sysAllowbid));
    }

    /**
     * 修改允许竞价
     */
    @GetMapping("/edit/{allowBidId}")
    public String edit(@PathVariable("allowBidId") Long allowBidId, ModelMap mmap)
    {
        SysAllowbid sysAllowbid = sysAllowbidService.selectSysAllowbidById(allowBidId);
        mmap.put("sysAllowbid", sysAllowbid);
        return prefix + "/edit";
    }

    /**
     * 修改保存允许竞价
     */
    @RequiresPermissions("system:allowbid:edit")
    @Log(title = "允许竞价", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysAllowbid sysAllowbid)
    {
        return toAjax(sysAllowbidService.updateSysAllowbid(sysAllowbid));
    }

    /**
     * 删除允许竞价
     */
    @RequiresPermissions("system:allowbid:remove")
    @Log(title = "允许竞价", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysAllowbidService.deleteSysAllowbidByIds(ids));
    }
}
